<?php

namespace app\admin\controller;

use think\facade\App;

class Finance extends Base {
    
    
    /**
     * @desc 提现列表
     */
    public function withdraw() {
        $params['userName']    = input('userName', '', 'trim');
        $params['orderNo']     = input('orderNo');
        $params['accountName'] = input('accountName');
        
        $logic = App::model('Finance', 'logic');
        $data = $logic->withdraw($params);
        
        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 银行卡信息
     */
    public function bankCard() {
        $params['userName']    = input('userName', '', 'trim');
        $params['orderNo']     = input('orderNo');
        $params['accountName'] = input('accountName');
        
        $logic = App::model('Finance', 'logic');
        $data = $logic->bankCard($params);
        
        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 订单锁定
     */
    public function withdrawLocking() {
        $params['id']       = input('id');
        
        $logic = model('Finance', 'logic');
        $data = [];
        try {
            $data = $logic->withdrawLocking($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
    
    
    /**
     * @desc 确认提现
     */
    public function withdrawConfirm() {
        $params['id']       = input('id');
        
        $logic = model('Finance', 'logic');
        $data = [];
        try {
            $data = $logic->withdrawConfirm($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
    
    /**
     * @desc 拒绝提现
     */
    public function withdrawRefuse() {
        $params['id']     = input('id');
        
        $logic = model('Finance', 'logic');
        $data = [];
        try {
            $data = $logic->withdrawRefuse($params, $this->memberInfo);
        } catch (\Exception $e) {
            $logic->errorCode = EC_FAILURE;
            $logic->message = $e->getMessage();
        }
        return send_response($data, $logic->errorCode, $logic->message);
    }
    
    /**
     * @desc 用户钱包
     * @return \think\response\View
     */
    public function userWallet() {
        $params['userName']    = input('userName', '', 'trim');
        $params['orderNo']     = input('orderNo');
        $params['accountName'] = input('accountName');
    
        $logic = App::model('Finance', 'logic');
        $data = $logic->userWallet($params);
    
        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 冻结记录
     */
    public function freezeRecord() {
        $params['id'] = input('id', 0);
        
        $logic = App::model('Finance', 'logic');
        $data = $logic->freezeRecord($params);
        
        $this->assign($data);
        return view();
    }
    
    /**
     * @desc 金流记录
     */
    public function accountRecord() {
        $params['id'] = input('id', 0);
        
        $logic = App::model('Finance', 'logic');
        $data = $logic->accountRecord($params);
        
        $this->assign($data);
        return view();
    }
}
